* Estimating 2025 using model from "forecast_5.do"

cd "D:\Forecast Bundestag 2025 Mary"

use forecast_5_2025_official,clear

* Figure 1


twoway (bar mean_27 land_enc, fcolor(gs8%50) lcolor(white)) ///
(scatter mean_27 land_enc, mcolor(none) mlabel(mean_27) ///
mlabformat(%8.1f) mlabpos(12)), ///
ylabel(0(5)45, grid angle(0)) xlabel(1(1)16, valuelabel) ///
xtitle("State") ytitle("Predicted vote share (%)") ///
legend(off) title("Model 2") 

graph save m2_2025.gph, replace

twoway (bar mean_27a land_enc, fcolor(gs8%50) lcolor(white)) ///
(scatter mean_27a land_enc, mcolor(none) mlabel(mean_27a) ///
mlabformat(%8.1f) mlabpos(12)), ///
ylabel(0(5)45, grid angle(0)) xlabel(1(1)16, valuelabel) ///
xtitle("State") ytitle("Predicted vote share (%)") ///
legend(off) title("Model 1") 

graph save m1_2025.gph, replace

graph combine m1_2025.gph m2_2025.gph, col(2) ysize(4) xsize(8) ///
title("Predicted State-Level CDU/CSU Result") ///
 subtitle("for the Bundestag Election 2025") 

graph export forecast_2025.png, replace

* Figure 2


* South-West model 1

twoway (line union_m1 election_year if land == "BY" & election_year > 1969, ///
lcolor(gs1) lpattern(solid)) ///
(line union_m1 election_year if land == "BW" & election_year > 1969, lcolor(gs1) ///
 lpattern(dash)) ///
(line union_m1 election_year if land == "RP" & election_year > 1969, lcolor(gs5) ///
lpattern(solid) lwidth(thick)) ///
(line union_m1 election_year if land == "NW" & election_year > 1969, lcolor(gs5) ///
lpattern(dash) lwidth(thick)) ///
(line union_m1 election_year if land == "HE" & election_year > 1969, lcolor(gs8) ///
lpattern(solid)) ///
(line union_m1 election_year if land == "SL" & election_year > 1969, lcolor(gs8) ///
lpattern(dash)), ///
ylabel(0(10)60, angle(0)) xlabel(1972 1976 1980 1983 1987 1990 1994 1998 ///
2002 2005 2009 2013 2017 2021 2025, alternate) ///
legend(order(1 "Bayern" 2 "Baden-Württemberg" 3 "Rheinland-Pfalz" ///
4 "Nordrhein-Westfalen" 5 "Hessen" 6 "Saarland")) ///
xtitle("") ytitle("vote share (%)") title("South & West: Model 1")

graph save south_m1, replace

* Stadtstaaten model 1

twoway (line union_m1 election_year if land == "SH" & election_year > 1969, ///
lcolor(gs1) lpattern(solid)) ///
(line union_m1 election_year if land == "NI" & election_year > 1969, lcolor(gs1) ///
 lpattern(dash)) ///
(line union_m1 election_year if land == "BE" & election_year > 1969, lcolor(gs5) ///
lpattern(solid) lwidth(thick)) ///
(line union_m1 election_year if land == "HH" & election_year > 1969, lcolor(gs5) ///
lpattern(dash) lwidth(thick)) ///
(line union_m1 election_year if land == "HB" & election_year > 1969, lcolor(gs8) ///
lpattern(solid)), ///
ylabel(0(10)60, angle(0)) xlabel(1972 1976 1980 1983 1987 1990 1994 1998 ///
2002 2005 2009 2013 2017 2021 2025, alternate) ///
legend(order(1 "Schleswig-Holstein" 2 "Niedersachsen" 3 "Berlin" ///
4 "Hamburg" 5 "Bremen")) ///
xtitle("") ytitle("vote share (%)") title("North & City-States: Model 1")

graph save north_m1, replace

* Ost model 1

twoway (line union_m1 election_year if land == "SN" & election_year > 1969, ///
lcolor(gs1) lpattern(solid)) ///
(line union_m1 election_year if land == "TH" & election_year > 1969, lcolor(gs1) ///
 lpattern(dash)) ///
(line union_m1 election_year if land == "ST" & election_year > 1969, lcolor(gs5) ///
lpattern(solid) lwidth(thick)) ///
(line union_m1 election_year if land == "MV" & election_year > 1969, lcolor(gs5) ///
lpattern(dash) lwidth(thick)) ///
(line union_m1 election_year if land == "BB" & election_year > 1969, lcolor(gs8) ///
lpattern(solid)), ///
ylabel(0(10)60, angle(0)) xlabel(1990 1994 1998 ///
2002 2005 2009 2013 2017 2021 2025, alternate) ///
legend(order(1 "Sachsen" 2 "Thüringen" 3 "Sachsen-Anhalt" ///
4 "Mecklenburg-Vorpommern" 5 "Brandenburg")) ///
xtitle("") ytitle("vote share (%)") title("East: Model 1")

graph save east_m1, replace

graph combine south_m1.gph north_m1.gph east_m1.gph, col(3) ///
ysize(4) xsize(12) 

graph export historical_model_1.png, replace


*********************

* South-West model 2

twoway (line union_m2 election_year if land == "BY" & election_year > 1969, ///
lcolor(gs1) lpattern(solid)) ///
(line union_m2 election_year if land == "BW" & election_year > 1969, lcolor(gs1) ///
 lpattern(dash)) ///
(line union_m2 election_year if land == "RP" & election_year > 1969, lcolor(gs5) ///
lpattern(solid) lwidth(thick)) ///
(line union_m2 election_year if land == "NW" & election_year > 1969, lcolor(gs5) ///
lpattern(dash) lwidth(thick)) ///
(line union_m2 election_year if land == "HE" & election_year > 1969, lcolor(gs8) ///
lpattern(solid)) ///
(line union_m2 election_year if land == "SL" & election_year > 1969, lcolor(gs8) ///
lpattern(dash)), ///
ylabel(0(10)60, angle(0)) xlabel(1972 1976 1980 1983 1987 1990 1994 1998 ///
2002 2005 2009 2013 2017 2021 2025, alternate) ///
legend(order(1 "Bayern" 2 "Baden-Württemberg" 3 "Rheinland-Pfalz" ///
4 "Nordrhein-Westfalen" 5 "Hessen" 6 "Saarland")) ///
xtitle("") ytitle("vote share (%)") title("South & West: Model 2")

graph save south_m2, replace

* Stadtstaaten model 2

twoway (line union_m2 election_year if land == "SH" & election_year > 1969, ///
lcolor(gs1) lpattern(solid)) ///
(line union_m2 election_year if land == "NI" & election_year > 1969, lcolor(gs1) ///
 lpattern(dash)) ///
(line union_m2 election_year if land == "BE" & election_year > 1969, lcolor(gs5) ///
lpattern(solid) lwidth(thick)) ///
(line union_m2 election_year if land == "HH" & election_year > 1969, lcolor(gs5) ///
lpattern(dash) lwidth(thick)) ///
(line union_m2 election_year if land == "HB" & election_year > 1969, lcolor(gs8) ///
lpattern(solid)), ///
ylabel(0(10)60, angle(0)) xlabel(1972 1976 1980 1983 1987 1990 1994 1998 ///
2002 2005 2009 2013 2017 2021 2025, alternate) ///
legend(order(1 "Schleswig-Holstein" 2 "Niedersachsen" 3 "Berlin" ///
4 "Hamburg" 5 "Bremen")) ///
xtitle("") ytitle("vote share (%)") title("North & City-States: Model 2")

graph save north_m2, replace

* Ost model 2

twoway (line union_m2 election_year if land == "SN" & election_year > 1969, ///
lcolor(gs1) lpattern(solid)) ///
(line union_m2 election_year if land == "TH" & election_year > 1969, lcolor(gs1) ///
 lpattern(dash)) ///
(line union_m2 election_year if land == "ST" & election_year > 1969, lcolor(gs5) ///
lpattern(solid) lwidth(thick)) ///
(line union_m2 election_year if land == "MV" & election_year > 1969, lcolor(gs5) ///
lpattern(dash) lwidth(thick)) ///
(line union_m2 election_year if land == "BB" & election_year > 1969, lcolor(gs8) ///
lpattern(solid)), ///
ylabel(0(10)60, angle(0)) xlabel(1990 1994 1998 ///
2002 2005 2009 2013 2017 2021 2025, alternate) ///
legend(order(1 "Sachsen" 2 "Thüringen" 3 "Sachsen-Anhalt" ///
4 "Mecklenburg-Vorpommern" 5 "Brandenburg")) ///
xtitle("") ytitle("vote share (%)") title("East: Model 2")

graph save east_m2, replace

graph combine south_m2.gph north_m2.gph east_m2.gph, col(3) ///
ysize(4) xsize(12) 

graph export historical_model_2.png, replace
 